package com.ctshk.rpc.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ctshk.rpc.finance.dto.supplier.SupplierReconciliationListDTO;
import com.ctshk.rpc.finance.entity.FinanceSupplierReconciliation;
import com.ctshk.rpc.finance.req.supplier.SupplierReconciliationListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 财务供应商对账单 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-08
 */
public interface FinanceSupplierReconciliationMapper extends BaseMapper<FinanceSupplierReconciliation> {

    /**
     * 供应商对账列表
     * @param iPage
     * @param req
     * @return
     */
    @Select("<script>SELECT a.id,a.supplier_name,a.reconciliation_number,a.expect_pay_time,a.approval_status,a.create_id,a.gmt_create,a.pay_status\n" +
            "FROM t_finance_supplier_reconciliation a\n" +
            "WHERE a.is_deleted = 0\n" +
            "<if test=\"req.reconciliationNumber != null and req.reconciliationNumber != ''\">AND a.reconciliation_number LIKE CONCAT('%',#{req.reconciliationNumber},'%')</if> \n" +
            "<if test=\"req.createTimeBegin != null and req.createTimeEnd != null\">AND a.gmt_create BETWEEN #{req.createTimeBegin} AND #{req.createTimeEnd}</if> \n" +
            "<if test=\"req.createId != null\">AND a.create_id = #{req.createId}</if> \n" +
            "<if test=\"req.supplierId != null\">AND a.supplier_id = #{req.supplierId}</if> \n" +
            "<if test=\"req.approvalStatus != null\">AND a.approval_status = #{req.approvalStatus}</if> \n" +
            "ORDER BY a.gmt_create DESC</script>")
    Page<SupplierReconciliationListDTO> queryListByCondition(@Param("iPage") Page<SupplierReconciliationListDTO> iPage, @Param("req") SupplierReconciliationListReq req);
}
